const http = require("../../Http/http")
Page({
    data: {
        movies: [],
        total: ""
    },
    onLoad() {
        http({
            offset:0,
            limit:5,
            success: res => {
                console.log(res.data);
                var { data, total } = res.data;
                this.setData({
                    movies: data,
                    total:this.handleNum(total)
                })
            }
        })
    },
    handleNum(num) {
        var arr = []
        for (var i = 0; i < num / 5; i++) {
            arr.push(i);
        }
        return arr;
    },
    handleItem(event){
        var {index} = event.currentTarget.dataset;
     var offset  = index *=5;
        console.log(index)
        this.sendHttp(offset)
      
    },
    sendHttp(offset){
        http({
            limit:5,
            offset:offset,
            success:res=>{
                var {data,total} = res.data;
                this.setData({
                    movies:data,
                    total:this.handleNum(total)
                })
            }
        })
    }
})